import React, { Component } from 'react';
import {Popup} from 'antd-mobile'
import FooterRegionAlertMaskList from './FooterRegionAlertMaskList'
import style from './footerRegionAlertMask.scss'

class FooterRegionAlertMask extends Component {
    constructor(props) {
        super(props);
        this.state = {
	        currentIndex: '',  //默认的选择
        };
    }

		componentWillMount(){

		}

		componentDidMount() {

		}

	  componentWillUnmount(){

	  }

		onCurrentIndex(index){
			this.setState({
				currentIndex: index==this.state.currentIndex?-1:index
			})
			  // sessionStorage.setItem("visaCurrentIndex", index);  //缓存选择
		}

		cancel(){
			this.props.choose(-1,'','cl',-1)
		}

    render() {
        return (
            <div className={style.footerAlertBox}>
               <ul className={style.listType}>
	               {
		               this.props.regionDataType.map((e,i)=>{

	               	  	return <FooterRegionAlertMaskList key={i}
		                                              index={i}
		                                              data={e}
		                                              currentIndex={this.state.currentIndex||this.props.index}
		                                              onCurrentIndex={(index)=>{this.onCurrentIndex(index)}}
		                                              onClick={(name,currentIndex,times,index)=>{this.props.choose(name,currentIndex,times,index)}}


		                  />
	                  })
	               }
	               {/*<div className={style.cancel_btn} onClick={()=>{this.cancel()}}>取消选择</div>*/}
               </ul>

                <div style={{height: '.38rem',background: '#f1f1f1'}}></div>
                <div className={style.btn} onClick={()=>{this.cancel();Popup.hide()}}>取消选择</div>
            </div>
        )
    }
}

FooterRegionAlertMask.defaultProps = {
	regionDataType: [{index: 0,currentIndex: 1,check:'free',name:'广东户籍港澳个人旅游再次签注(自由行)'},{index: 1,currentIndex:3,check:'again',name:'广东企业港澳商务再次签注'},
	       {index: 2, currentIndex:4,check:'spouse',name:'广东户籍港澳夫妻探亲再次签注'},{index: 3, currentIndex:5,check:'sz',name:'深圳非广东省户籍就业就读人员往来港澳个人旅游再次签注'}],
	visaIndex: 0  //默认的选择
}

export default FooterRegionAlertMask